<template>
    <div class="prompt-box" v-if="visible">
        <div class="box">
            <div class="title" v-if="title">{{title}}</div>
            <div class="content">{{content}}</div>
            <div class="bottom">
                <div class="submit btn" @click="handleOk">确定</div>
                <div class="cancel btn" @click="handleCancel">取消</div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "PromptBox",
        props: {
            visible: {
                type: Boolean,
                default: false
            },
            title: {
                type: String,
                default: ''
            },
            content: {
                type: String,
                default: ''
            }
        },
        methods: {
            handleOk() {
                this.$emit('onOk')
            },
            handleCancel() {
                this.$emit('onCancel')
            }
        }
    }
</script>

<style scoped lang="less">
    .prompt-box {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, .4);
        z-index: 9999;
        
        .box {
            width: 400px;
            height: 177px;
            background-color: #fff;
            border-radius: 8px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            
            .title {
                margin-top: 48px;
                width: 100%;
                font-size: 18px;
                text-align: center;
                color: rgba(0, 0, 0, .8);
            }
            
            .bottom {
                .flexed(space-between);
                width: 304px;
                margin: 0 auto 24px;
                
                .btn {
                    width: 140px;
                    height: 40px;
                    border-radius: 4px;
                    text-align: center;
                    line-height: 40px;
                    font-size: 14px;
                    color: #000;
                    cursor: pointer;
                }
                
                .submit {
                    background-color: #ffdc20;
                }
                
                .cancel {
                    background-color: #fff;
                    border: 1px solid rgba(0, 0, 0, .4);
                }
            }
        }
    }
</style>
